import org.molamil.acto.params.ParamContext;

/**
 * @author Jorge Hernandez
 */
class org.molamil.acto.commands.CommandContext {
	
	
	// Constatns
	
	public static var PARAMS_LOSE:String = "lose";	public static var PARAMS_STRICT:String = "strict";
	
	public static var CACHE_DEFAULT:String = "default";
	public static var CACHE_CLEAR:String = "clear";
	public static var CACHE_ALL:String = "all";
	
	
	// Properties
	
	private var _name:String;
	private var _title:String;
	private var _target:String;
	private var _props:Object;
	private var _className:String;
	private var _depends:Array;	private var _params:Array;	private var _paramsMode:String;	private var _role:String;	private var _cache:String;
	
	
	// Constructor
	
	public function CommandContext() {
		_cache = CACHE_DEFAULT;
		props = new Object();
	}
	
	
	// Functions
	
	public function getParam(name:String):ParamContext {
		var param:ParamContext = null;
		for (var i:Number = 0;i < _params.length; i++) {
			var p:ParamContext = _params[i];
			if (p.name == name) {
				param = p;
				break;
			}
		}
		return param;
	}
	
	public function toString():String {
		var s:String = "org.molamil.acto.commands.CommandContext" +
					   "\n\t name = " + _name +
					   "\n\t title = " + _title +
					   "\n\t target = " + _target +
					   "\n\t props = " + _props +
					   "\n\t className = " + _className +
					   "\n\t role = " + _role +					   "\n\t cache = " + _cache +					   "\n\t paramsMode = " + _paramsMode +					   "\n\t depends = " + _depends +					   "\n\t params = " + _params;
		return s;
	}
	
	
	// Getter/Setter
	
	public function get name():String {
		return _name;
	}
	
	public function set name(name:String):Void {
		this._name = name;
	}
	
	public function get title():String {
		return _title;
	}
	
	public function set title(title:String):Void {
		this._title = title;
	}
		
	public function get target():String {
		return _target;
	}
	
	public function set target(target:String):Void {
		this._target = target;
	}
	
	public function get props():Object {
		return _props;
	}
	
	public function set props(props:Object):Void {
		this._props = props;
	}
	
	public function get className():String {
		return _className;
	}
	
	public function set className(className:String):Void {
		this._className = className;
	}
	
	public function get depends():Array {
		return _depends;
	}
	
	public function set depends(depends:Array):Void {
		this._depends = depends;
	}
	
	public function get params():Array {
		return _params;
	}
	
	public function set params(params:Array):Void {
		this._params = params;
	}
	
	public function get paramsMode():String {
		return _paramsMode;
	}

	public function set paramsMode(paramsMode:String):Void {
		this._paramsMode = paramsMode;
	}
	
	public function get role():String {
		return _role;
	}
	
	public function set role(role:String):Void {
		this._role = role;
	}
	
	public function get cache():String {
		return _cache;
	}
	
	public function set cache(cache:String):Void {
		this._cache = cache;
	}
	
	
}
